package lib.bone.access.validator;

import lib.bone.access.constant.AwardTypeConst;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class IsAwardTypeValidator implements ConstraintValidator<IsAwardType, Object> {
    @Override
    public void initialize(IsAwardType constraintAnnotation) {
        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        String type = o.toString();
        if (type.equals(AwardTypeConst.RESEARCH) || type.equals(AwardTypeConst.TEACH)){
            return true;
        }
        return false;
    }
}
